<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>

    <script src="../lib/vue2.js"></script>
  </head>
  <body>
    <div id="box">
      <!-- v-if和v-else的组合使用 -->
      <div v-if="isCreated">1</div>
      <div v-else>2</div>

      <!-- template标签相当于一个不影响dom树的盒子，一般用于决定整个模块的切换或显示 -->
      <template v-if="isCreated">
        <ul>
          <li v-for="item in datalist">
            {{item.title}}---
            <!-- 通过状态码显示相对应文本 -->
            <span v-if="item.code === 0">未支付</span>
            <span v-else-if="item.code === 1">未发货</span>
            <span v-else-if="item.code === 2">已发货</span>
            <span v-else="item.code === 3">已签收</span>
          </li>
        </ul>
      </template>
    </div>

    <script>
      let item = new Vue({
        el: "#box",
        data: {
          isCreated: true,
          //   通过状态码标记
          datalist: [
            { title: "苹果", code: 0 },
            { title: "草莓", code: 1 },
            { title: "雪梨", code: 2 },
            { title: "西瓜", code: 3 },
          ],
        },
      });
    </script>
  </body>
</html>
